/**
 * Created by Luji on 2017/02/03.
 */
import temp from './dependency.html';
import ctrl from './dependency.ctrl.js';
import css from './dependency.scss';



import detailTemp from './detail/detail.html';
import detailCtrl from './detail/detail.ctrl.js';



export default angular.module('ctg-k8sconsole').config(['$stateProvider', $stateProvider=> {
    $stateProvider.state('app-dependency', {
        url: '/app/dependency',
        templateUrl: temp,
        controller: ctrl,
        controllerAs: 'list',
        resolve: {
            list: ['appSrv', 'ctgNotification', function (appSrv, ctgNotification) {
                return appSrv.getSerDepList({currentPage: 1}).catch(function (data) {
                    ctgNotification.error('获取服务依赖列表数据有误.');
                });
            }]
        }
    }).state('app-dependency-detail', {
        url: "/app/dependency/detail/:id",
        templateUrl: detailTemp,
        controller: detailCtrl,
        controllerAs: 'vm',
        resolve: {
            detail: ['appSrv', 'ctgNotification', '$stateParams', function (appSrv, ctgNotification, $stateParams) {
                if ($stateParams.id) {
                    return appSrv.getSerDepDetail($stateParams.id).catch(function (data) {
                        ctgNotification.error('获取服务依赖数据有误.');
                    });
                }

            }]
        }
    })
}]);